package com.cloudspace.yunloan.player.exo;

import com.cloudspace.yunloan.utils.Utility;
import com.google.android.exoplayer2.upstream.cache.Cache;
import com.google.android.exoplayer2.upstream.cache.NoOpCacheEvictor;
import com.google.android.exoplayer2.upstream.cache.SimpleCache;

import java.io.File;

/**
 * Created by xhb on 2018/7/19.
 */

public class ExoPlayerCacheController {

    private static ExoPlayerCacheController instance;
    private ExoPlayerCacheController() {
    }

    public static ExoPlayerCacheController getInstance() {
        if (instance == null) {
            instance = new ExoPlayerCacheController();
        }
        return instance;
    }

    private Cache downloadCache;
    public synchronized Cache getDownloadCache() {
        if (downloadCache == null) {
            File downloadContentDirectory = Utility.getSDPath();
            downloadCache = new SimpleCache(downloadContentDirectory, new NoOpCacheEvictor());
        }
        return downloadCache;
    }
}
